package face.pay.web.com.login.servcie;

import face.pay.common.user.service.UserRegisterBiz;
import face.pay.constant.UserType;
import face.pay.entity.UserInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * @Auther: zkj
 * @Date: 2019/7/11 15:25
 * @Description:
 */
@Service
public class LoginServiceImpl implements  IloginService {

    @Autowired
    UserRegisterBiz userRegisterBiz;

    @Override
    public UserInfo login(UserInfo user, String domain) {

        String userType= "";

        if(domain.startsWith("agency.")){
            userType=UserType.AGENCY;
        }else{
            userType=UserType.ENTERPRISE;
        }

        UserInfo userInfo =  this.userRegisterBiz.login(user,domain,userType);
        if(userInfo!=null){
            userInfo.setPassWord(null);
        }

        return userInfo;
    }



}
